﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 面向对象练习
{
    public class Student
    {
        //字段 属性 方法 构造函数
        public Student(string name,int age,char gendet,int chinese,int math,int english)
        {
            this.Name = name;
            this.Age = age;
            this.Gender = gendet;
            this.Chinese = chinese;
            this.English = english;
            this.Math = math;
        }

        private string _name;
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        private int _age;
        public int Age
        {
            get { return _age; }
            set {
                if (value < 0 && value > 100)
                {
                    value = 0;
                }
                
                _age = value; }
        }
        private char _gender;
        public char Gender
        {
            get {
                if (_gender != '男' && _gender != '女')
                {
                    return _gender = '男';
                }
                
                return _gender; }
            set { _gender = value; }
        }

        private int _chinese;
        public int Chinese
        {
            get { return _chinese; }
            set {
                if (value < 0 && value > 150)
                {
                    value = 0;
                }
                _chinese = value; }
        }
        private int _math;
        public int Math
        {
            get { return _math; }
            set {
                if (value < 0 && value > 150)
                {
                    value = 0;
                }
                _math = value; }
        }
        private int _english;
        public int English
        {
            get { return _english; }
            set {
                if (value < 0 && value > 150)
                {
                    value = '0' ;
                }
                _english = value; }
        }
        public void a()
        {
            Console.WriteLine("我的名字叫{0}，我今年{1}，我是一个{2}生",this.Name,this._age,this.Gender);
        }
        public void b()
        {
            Console.WriteLine("我叫{0}，我的总成绩是{1}，我的平均成绩是{2}", this.Name, this.Chinese + this.English + this.Math, (this.Chinese + this.English + this.Math) / 3);
        }
    }

}
